"use client";

import "./index.css";
import QuestionVO = API.QuestionVO;
import { Card, List } from "antd";
import Link from "next/link";
import TagList from "@/components/TagList"; // 组件的样式

// 组件接收的参数
interface Props {
  questionList: QuestionVO[];
}

// 根据参数返回组件渲染的结果
const QuestionList = (props: Props) => {
  const { questionList = [] } = props; // 解析参数
  // 返回渲染后的结果
  return (
    <div className="question-list">
      <Card>
        <List
          dataSource={questionList}
          renderItem={(item: QuestionVO) => (
            <List.Item extra={<TagList tagList={item.tagList} />}>
              <List.Item.Meta
                title={<Link href={"/question/" + item.id}>{item.title}</Link>}
              />
            </List.Item>
          )}
        />
      </Card>
    </div>
  );
};

export default QuestionList;
